package com.guoxin.chapter3.waitnotify.producerconsumerallwait;

/**
 * @author guoxin
 * @date 2019年8月22日
 */
public class Consumer {
	private Object lock;

	public Consumer(Object lock) {
		super();
		this.lock = lock;
	}

	public void getValue() {
		try {
			synchronized (lock) {
				while (ValueObject.value.equals("")) {
					System.out.println("消费者 " + Thread.currentThread().getName() + " WAITING 了☆");
					lock.wait();
				}
				System.out.println("消费者 " + Thread.currentThread().getName() + " RUNNABLE 了");
				ValueObject.value = "";
				lock.notify();
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
